// pages/new_doc/orderList/index.js
var app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    shop_type:1,
    dataList:[],
    now_page:1,
    total_page:0
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.setData({
      shop_type:wx.getStorageSync("shop_type"),
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
    
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    this.getData();
  },
  getData(now_page = 1){
    var that = this;
    var shopid = wx.getStorageSync("shop_id");
    let url = 'api/shopr/carOrder'
    this.setData({
      shopid:shopid,
    })
    var param = {
      url: url,
      data: {
        shop_id: shopid,
        type:"",
        now_page:now_page
      },
      success:(e)=> {
        let res = e.data.data;
        this.setData({
          dataList:this.data.dataList.concat(res.list),
          total_page:res.total_page
        })

      }
    };
    app.post(param);
  },
  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
    let now_page = this.data.now_page;
    console.log(now_page,this.data.total_page)
    if(now_page < this.data.total_page){
      now_page++;
      this.setData({
        now_page:now_page
      })
      this.getData(now_page)
    }
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})